package com.lyx.TestList;

import com.lyx.TestTreeSet.TestComparator;
import com.lyx.entity.Student;

import java.util.*;

public class TestSet02 {



    public static void main(String[] args) {


        HashSet<Student> hashSet = new HashSet<Student>();

        LinkedHashSet<Student> linkedHashSet = new LinkedHashSet<Student>();

        TestComparator testComparator = new TestComparator();
        //Set<Student> studentSet = new TreeSet<Student>(testComparator);
        TreeSet<Student> studentSet = new TreeSet<Student>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getId() - o2.getId();
            }
        });

        Student student1 = new Student(1,"张三",16,90.3);
        Student student2 = new Student(2,"李四",16,89.5);
        Student student3 = new Student(3,"老六",16,55.0);
        Student student4 = new Student(4,"王五",16,80.0);
        Student student5 = new Student(3,"老六",16,55.0);
        System.out.println(studentSet.size());

        hashSet.add(student1);
        hashSet.add(student2);

        linkedHashSet.add(student2);
        linkedHashSet.add(student2);

        studentSet.add(student1);
        studentSet.add(student2);
        studentSet.add(student3);
        studentSet.add(student4);
        studentSet.add(student5);

        Iterator<Student> iterator = studentSet.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        System.out.println(studentSet.size());


    }
}
